1 <?php
2     include(
"../includes/config.php");
3     include(
"../includes/validate_data.php");
4     session_start();
5     
if(isset($_SESSION['manufacturer_login'])) {
6         $id = $_SESSION[
'manufacturer_id'];
7         $requireErr = $oldPasswordErr = $matchErr =
"";
8         
if($_SERVER['REQUEST_METHOD'] == "POST") {
9             
if(!empty($_POST['txtOldPassword'])){
10                 $password = $_POST[
'txtOldPassword'];
11                 $query_oldPassword =
"SELECT password FROM manufacturer WHERE man_id='$id' AND password='$password'";
12                 $result_oldPassword = mysqli_query($con,$query_oldPassword);
13                 $row_oldPassword = mysqli_fetch_array($result_oldPassword);
14                 
if($row_oldPassword) {
15                     
if(!empty($_POST['txtNewPassword']) && !empty($_POST['txtConfirmPassword'])){
16                         $newPassword = $_POST[
'txtNewPassword'];
17                         $confirmPassword = $_POST[
'txtConfirmPassword'];
18                         
if(strcmp($newPassword,$confirmPassword) == 0) {
19                             $query_UpdatePassword =
"UPDATE manufacturer SET password='$confirmPassword' WHERE man_id='$id'";
20                             
if(mysqli_query($con,$query_UpdatePassword)) {
21                                 echo
"<script> alert(\"Password Updated Successfully\"); </script>";
22                                 header(
"Refresh:0");
23                             }
24                             
else {
25                                 $requireErr =
"* Updating Password Failed";
26                             }
27                         }
28                         
else {
29                             $matchErr =
"* Password do not match";
30                         }
31                     }
32                     
else {
33                         $requireErr =
"* All Fields are required";
34                     }
35                 }
36                 
else {
37                     $oldPasswordErr =
"* Old Password do not match";
38                 }
39             }
40     }
41     }
42     
else {
43         header(
'Location:../index.php');
44     }
45 ?>
46 <!DOCTYPE html>
47 <html>
48 <head>
49     <title> Edit Profile </title>
50     <link rel=
"stylesheet" href="../includes/main_style.css" >
51 </head>
52 <body>
53     <?php
54         include(
"../includes/header.inc.php");
55         include(
"../includes/nav_manufacturer.inc.php");
56         include(
"../includes/aside_manufacturer.inc.php");
57     ?>
58     <section>
59         <h1>Edit Profile</h1>
60         <form action=
"" method="POST" class="form">
61         <ul
class="form-list">
62         <li>
63             <div
class="label-block"> <label for="oldPassword">Old Password</label> </div>
64             <div
class="input-box"> <input type="password" id="oldPassword" name="txtOldPassword" placeholder="Old Password" required /> </div> <span class="error_message"><?php echo $oldPasswordErr; ?></span>
65         </li>
66         <li>
67             <div
class="label-block"> <label for="newPassword">New Password</label> </div>
68             <div
class="input-box"> <input type="password" id="newPassword" name="txtNewPassword" placeholder="New Password" required /> </div>
69         </li>
70         <li>
71             <div
class="label-block"> <label for="confirmPassword">Confirm Password</label> </div>
72             <div
class="input-box"> <input type="password" id="confirmPassword" name="txtConfirmPassword" placeholder="Confirm Password" required /> </div><span class="error_message"><?php echo $matchErr; ?></span>
73         </li>
74         <li>
75             <input type=
"submit" value="Change Password" class="submit_button" /> <span class="error_message"> <?php echo $requireErr; ?>
76         </li>
77         </ul>
78         </form>
79     </section>
80     <?php
81         include(
"../includes/footer.inc.php");
82     ?>
83 </body>
84 </html>


Gõ tìm kiếm nhanh...